package subject_set.offer100;

import java.util.Deque;
import java.util.LinkedList;

class ListNode {
    int val;
    ListNode next;

    ListNode(int x) {
        val = x;
    }
}

/**
 * @author haomin
 * @date 2022/10/13 20:17
 **/
public class Offer06 {
    class Solution1 {
        public int[] reversePrint(ListNode head) {
            Deque<Integer> stack = new LinkedList<>();
            while(head != null){
                stack.push(head.val);
                head = head.next;
            }
            int[] ans = new int[stack.size()];
            int i = 0;
            while(!stack.isEmpty()) {
                ans[i] = stack.poll();
                i++;
            }
            return ans;
        }
    }
}